﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BussinessLogic
{
    public class LogicController
    {
        #region Singleton

        private LogicController()
        { }

        private static LogicController s_instance;
        private static object s_instanceMutex = new object();

        public static void EnsureSingletonLoaded()
        {
            if (s_instance == null)
            {
                lock (s_instanceMutex)
                {
                    if (s_instance == null)
                    {
                        var mt = new LogicController();
                        s_instance = mt;
                    }
                }
            }
        }

        public static LogicController Instance
        {
            get
            {
                EnsureSingletonLoaded();
                return s_instance;
            }
        }

        #endregion

        private AdminManager m_adminManagerManager;
        private object m_adminManagerManagerMutex = new object();
        public AdminManager AdminManager
        {
            get
            {
                if (m_adminManagerManager == null)
                {
                    lock (m_adminManagerManagerMutex)
                    {
                        if (m_adminManagerManager == null)
                        {
                            m_adminManagerManager = new AdminManager();
                        }
                    }
                }
                return this.m_adminManagerManager;
            }
        }

        private ProductManager m_productManagerManager;
        private object m_productManagerManagerMutex = new object();
        public ProductManager ProductManager
        {
            get
            {
                if (m_productManagerManager == null)
                {
                    lock (m_productManagerManagerMutex)
                    {
                        if (m_productManagerManager == null)
                        {
                            m_productManagerManager = new ProductManager();
                        }
                    }
                }
                return this.m_productManagerManager;
            }
        }
    }
}
